
#ifndef CUTOFFOPERATION_H
#define CUTOFFOPERATION_H

#include <BMap>
#include <BHBoxLayout>
#include <BButton>

#include <BEventFilter>

using namespace BWE;

class CutoffOperation : public BEventFilter
{
public:
	CutoffOperation();
	~CutoffOperation();

protected:
	void freshPartRects();
	void applyPartDraging(const BPoint& pos);

protected:
	void slotApplyButtonClicked();
	void slotCancelButtonClicked();

private:
	virtual void attached(BWidget* widget);
	virtual void detached(BWidget* widget);

	virtual void paintEvent(const BEvent& event);
	virtual void updateEvent(const BEvent& event);

	virtual void freshEvent(const BEvent& event);
	virtual void focusEvent(const BEvent& event);

	virtual void keyPressEvent(const BKeyEvent& keyEvent);
	virtual void keyReleaseEvent(const BKeyEvent& keyEvent);

	virtual void mouseEnterEvent(const BMouseEvent& mouseEvent);
	virtual void mouseLeaveEvent(const BMouseEvent& mouseEvent);
	virtual void mousePressEvent(const BMouseEvent& mouseEvent);
	virtual void mouseReleaseEvent(const BMouseEvent& mouseEvent);
	virtual void mouseMoveEvent(const BMouseEvent& mouseEvent);

	virtual void mouseWheelEvent(const BMouseEvent& mouseEvent);
	virtual void mouseClickEvent(const BMouseEvent& mouseEvent);
	virtual void mouseDoubleClickEvent(const BMouseEvent& mouseEvent);

private:
	BHBoxLayoutHolder	_layout;
	BButton*			_applyButton;
	BButton*			_cancelButton;

	BPoint				_hoverPoint;
	BPoint				_pressPoint;
	BRect				_selectRect;
	bool				_draging;
	BPoint				_dragPoint;
	Part				_dragPart;
	BMap<PartFlag, BRect>	_dragRectMap;
};

#endif
